<?php
/**
 * 幻灯片服务层
 * @author maniac
 */
namespace app\common\service;

use app\common\model\Slides AS SlidesModel;

class Slides extends Base
{
    /**
     * 获取幻灯片信息
     * @param array  $category_id 幻灯片分类 id
     * @param int    $limit       查询的数量
     * @param string $order       排序条件
     */
    public function slides($category_id, $limit = '',$field ='id,image_id,title,type,url' ,$order = 'list_order DESC,id ASC')
    {
        if (is_numeric($category_id)) {
            $where[] = [
                ['category_id','eq',$category_id]
            ];
        } else {
            $where[] = [
                ['category_id', 'in', $category_id],
            ];
        }

        return SlidesModel::field($field)->append(['image_uri'])->where($where)->order($order)->limit($limit)->select()->toArray();
       // return SlidesModel::field('id,image_id,title,type,url,description')->append(['image_uri','tumb_uri'])->where($where)->order($order)->limit($limit)->select()->toArray();
    }
}
